#!/usr/bin/env python

import sys, os
from pyjon import jsparser, node2json

def main(args):
    if len(args)>1:
        f = file(args[1], 'r')
        script = f.read()
    else:
        script = sys.stdin.read()
    t = jsparser.parse(script)
    print node2json.convert(t)
    return 0

if __name__ == "__main__":
    sys.exit(main(sys.argv))



